package co.edu.usbcali.museo.presentation.businessDelegate;

import co.edu.usbcali.museo.modelo.Autor;
import co.edu.usbcali.museo.modelo.Cuadro;
import co.edu.usbcali.museo.modelo.Museo;
import co.edu.usbcali.museo.modelo.Periodo;
import co.edu.usbcali.museo.modelo.Restauracion;
import co.edu.usbcali.museo.modelo.Sesion;
import co.edu.usbcali.museo.modelo.Tecnica;
import co.edu.usbcali.museo.modelo.Tipoestado;
import co.edu.usbcali.museo.modelo.control.AutorLogic;
import co.edu.usbcali.museo.modelo.control.CuadroLogic;
import co.edu.usbcali.museo.modelo.control.IAutorLogic;
import co.edu.usbcali.museo.modelo.control.ICuadroLogic;
import co.edu.usbcali.museo.modelo.control.IMuseoLogic;
import co.edu.usbcali.museo.modelo.control.IPeriodoLogic;
import co.edu.usbcali.museo.modelo.control.IRestauracionLogic;
import co.edu.usbcali.museo.modelo.control.ISesionLogic;
import co.edu.usbcali.museo.modelo.control.ITecnicaLogic;
import co.edu.usbcali.museo.modelo.control.ITipoestadoLogic;
import co.edu.usbcali.museo.modelo.control.MuseoLogic;
import co.edu.usbcali.museo.modelo.control.PeriodoLogic;
import co.edu.usbcali.museo.modelo.control.RestauracionLogic;
import co.edu.usbcali.museo.modelo.control.SesionLogic;
import co.edu.usbcali.museo.modelo.control.TecnicaLogic;
import co.edu.usbcali.museo.modelo.control.TipoestadoLogic;

import java.math.BigDecimal;

import java.util.Date;
import java.util.List;
import java.util.Set;


/**
* Use a Business Delegate to reduce coupling between presentation-tier clients and business services.
* The Business Delegate hides the underlying implementation details of the business service, such as lookup and access details of the EJB architecture.
*
* The Business Delegate acts as a client-side business abstraction; it provides an abstraction for, and thus hides,
* the implementation of the business services. Using a Business Delegate reduces the coupling between presentation-tier clients and
* the system's business services. Depending on the implementation strategy, the Business Delegate may shield clients from possible
* volatility in the implementation of the business service API. Potentially, this reduces the number of changes that must be made to the
* presentation-tier client code when the business service API or its underlying implementation changes.
*
* However, interface methods in the Business Delegate may still require modification if the underlying business service API changes.
* Admittedly, though, it is more likely that changes will be made to the business service rather than to the Business Delegate.
*
* Often, developers are skeptical when a design goal such as abstracting the business layer causes additional upfront work in return
* for future gains. However, using this pattern or its strategies results in only a small amount of additional upfront work and provides
* considerable benefits. The main benefit is hiding the details of the underlying service. For example, the client can become transparent
* to naming and lookup services. The Business Delegate also handles the exceptions from the business services, such as java.rmi.Remote
* exceptions, Java Messages Service (JMS) exceptions and so on. The Business Delegate may intercept such service level exceptions and
* generate application level exceptions instead. Application level exceptions are easier to handle by the clients, and may be user friendly.
* The Business Delegate may also transparently perform any retry or recovery operations necessary in the event of a service failure without
* exposing the client to the problem until it is determined that the problem is not resolvable. These gains present a compelling reason to
* use the pattern.
*
* Another benefit is that the delegate may cache results and references to remote business services. Caching can significantly improve performance,
* because it limits unnecessary and potentially costly round trips over the network.
*
* A Business Delegate uses a component called the Lookup Service. The Lookup Service is responsible for hiding the underlying implementation
* details of the business service lookup code. The Lookup Service may be written as part of the Delegate, but we recommend that it be
* implemented as a separate component, as outlined in the Service Locator pattern (See "Service Locator" on page 368.)
*
* When the Business Delegate is used with a Session Facade, typically there is a one-to-one relationship between the two.
* This one-to-one relationship exists because logic that might have been encapsulated in a Business Delegate relating to its interaction
* with multiple business services (creating a one-to-many relationship) will often be factored back into a Session Facade.
*
* Finally, it should be noted that this pattern could be used to reduce coupling between other tiers, not simply the presentation and the
* business tiers.
*
* @author Zathura Code Generator http://code.google.com/p/zathura
*j
*/
public class BusinessDelegatorView {
    private BusinessDelegatorView() {
    }

    public static List<Autor> getAutor() throws Exception {
        IAutorLogic autorLogic = new AutorLogic();

        return autorLogic.getAutor();
    }

    public static void saveAutor(Long codautor, String nombreautor)
        throws Exception {
        IAutorLogic autorLogic = new AutorLogic();
        autorLogic.saveAutor(codautor, nombreautor);
    }

    public static void deleteAutor(Long codautor) throws Exception {
        IAutorLogic autorLogic = new AutorLogic();
        autorLogic.deleteAutor(codautor);
    }

    public static void updateAutor(Long codautor, String nombreautor)
        throws Exception {
        IAutorLogic autorLogic = new AutorLogic();
        autorLogic.updateAutor(codautor, nombreautor);
    }

    public static Autor getAutor(Long codautor) throws Exception {
        IAutorLogic autorLogic = new AutorLogic();
        Autor autor = null;

        try {
            autor = autorLogic.getAutor(codautor);
        } catch (Exception e) {
            throw e;
        }

        return autor;
    }

    public static List<Autor> findByCriteriaInAutor(Object[] variables,
        Object[] variablesBetween, Object[] variablesBetweenDates)
        throws Exception {
        IAutorLogic autorLogic = new AutorLogic();

        return autorLogic.findByCriteria(variables, variablesBetween,
            variablesBetweenDates);
    }

    public static List<Autor> findPageAutor(String sortColumnName,
        boolean sortAscending, int startRow, int maxResults)
        throws Exception {
        IAutorLogic autorLogic = new AutorLogic();

        return autorLogic.findPageAutor(sortColumnName, sortAscending,
            startRow, maxResults);
    }

    public static Long findTotalNumberAutor() throws Exception {
        IAutorLogic autorLogic = new AutorLogic();

        return autorLogic.findTotalNumberAutor();
    }

    public static List<Cuadro> getCuadro() throws Exception {
        ICuadroLogic cuadroLogic = new CuadroLogic();

        return cuadroLogic.getCuadro();
    }

    public static void saveCuadro(Long codcuadro, Date fechaentradamuseo,
        Date fechaultimarestauracion, String nombrecuadro,
        Double valoreconomico, Double valorrecaudado, Long codautor_Autor,
        Long codperiodo_Periodo, Long codtecnica_Tecnica,
        Long codtipoestado_Tipoestado) throws Exception {
        ICuadroLogic cuadroLogic = new CuadroLogic();
        cuadroLogic.saveCuadro(codcuadro, fechaentradamuseo,
            fechaultimarestauracion, nombrecuadro, valoreconomico,
            valorrecaudado, codautor_Autor, codperiodo_Periodo,
            codtecnica_Tecnica, codtipoestado_Tipoestado);
    }

    public static void deleteCuadro(Long codcuadro) throws Exception {
        ICuadroLogic cuadroLogic = new CuadroLogic();
        cuadroLogic.deleteCuadro(codcuadro);
    }

    public static void updateCuadro(Long codcuadro, Date fechaentradamuseo,
        Date fechaultimarestauracion, String nombrecuadro,
        Double valoreconomico, Double valorrecaudado, Long codautor_Autor,
        Long codperiodo_Periodo, Long codtecnica_Tecnica,
        Long codtipoestado_Tipoestado) throws Exception {
        ICuadroLogic cuadroLogic = new CuadroLogic();
        cuadroLogic.updateCuadro(codcuadro, fechaentradamuseo,
            fechaultimarestauracion, nombrecuadro, valoreconomico,
            valorrecaudado, codautor_Autor, codperiodo_Periodo,
            codtecnica_Tecnica, codtipoestado_Tipoestado);
    }

    public static Cuadro getCuadro(Long codcuadro) throws Exception {
        ICuadroLogic cuadroLogic = new CuadroLogic();
        Cuadro cuadro = null;

        try {
            cuadro = cuadroLogic.getCuadro(codcuadro);
        } catch (Exception e) {
            throw e;
        }

        return cuadro;
    }

    public static List<Cuadro> findByCriteriaInCuadro(Object[] variables,
        Object[] variablesBetween, Object[] variablesBetweenDates)
        throws Exception {
        ICuadroLogic cuadroLogic = new CuadroLogic();

        return cuadroLogic.findByCriteria(variables, variablesBetween,
            variablesBetweenDates);
    }

    public static List<Cuadro> findPageCuadro(String sortColumnName,
        boolean sortAscending, int startRow, int maxResults)
        throws Exception {
        ICuadroLogic cuadroLogic = new CuadroLogic();

        return cuadroLogic.findPageCuadro(sortColumnName, sortAscending,
            startRow, maxResults);
    }

    public static Long findTotalNumberCuadro() throws Exception {
        ICuadroLogic cuadroLogic = new CuadroLogic();

        return cuadroLogic.findTotalNumberCuadro();
    }

    public static List<Museo> getMuseo() throws Exception {
        IMuseoLogic museoLogic = new MuseoLogic();

        return museoLogic.getMuseo();
    }

    public static void saveMuseo(Long codmuseo, String nombremuseo)
        throws Exception {
        IMuseoLogic museoLogic = new MuseoLogic();
        museoLogic.saveMuseo(codmuseo, nombremuseo);
    }

    public static void deleteMuseo(Long codmuseo) throws Exception {
        IMuseoLogic museoLogic = new MuseoLogic();
        museoLogic.deleteMuseo(codmuseo);
    }

    public static void updateMuseo(Long codmuseo, String nombremuseo)
        throws Exception {
        IMuseoLogic museoLogic = new MuseoLogic();
        museoLogic.updateMuseo(codmuseo, nombremuseo);
    }

    public static Museo getMuseo(Long codmuseo) throws Exception {
        IMuseoLogic museoLogic = new MuseoLogic();
        Museo museo = null;

        try {
            museo = museoLogic.getMuseo(codmuseo);
        } catch (Exception e) {
            throw e;
        }

        return museo;
    }

    public static List<Museo> findByCriteriaInMuseo(Object[] variables,
        Object[] variablesBetween, Object[] variablesBetweenDates)
        throws Exception {
        IMuseoLogic museoLogic = new MuseoLogic();

        return museoLogic.findByCriteria(variables, variablesBetween,
            variablesBetweenDates);
    }

    public static List<Museo> findPageMuseo(String sortColumnName,
        boolean sortAscending, int startRow, int maxResults)
        throws Exception {
        IMuseoLogic museoLogic = new MuseoLogic();

        return museoLogic.findPageMuseo(sortColumnName, sortAscending,
            startRow, maxResults);
    }

    public static Long findTotalNumberMuseo() throws Exception {
        IMuseoLogic museoLogic = new MuseoLogic();

        return museoLogic.findTotalNumberMuseo();
    }

    public static List<Periodo> getPeriodo() throws Exception {
        IPeriodoLogic periodoLogic = new PeriodoLogic();

        return periodoLogic.getPeriodo();
    }

    public static void savePeriodo(Long codperiodo, Date fechafin,
        Date fechainicio) throws Exception {
        IPeriodoLogic periodoLogic = new PeriodoLogic();
        periodoLogic.savePeriodo(codperiodo, fechafin, fechainicio);
    }

    public static void deletePeriodo(Long codperiodo) throws Exception {
        IPeriodoLogic periodoLogic = new PeriodoLogic();
        periodoLogic.deletePeriodo(codperiodo);
    }

    public static void updatePeriodo(Long codperiodo, Date fechafin,
        Date fechainicio) throws Exception {
        IPeriodoLogic periodoLogic = new PeriodoLogic();
        periodoLogic.updatePeriodo(codperiodo, fechafin, fechainicio);
    }

    public static Periodo getPeriodo(Long codperiodo) throws Exception {
        IPeriodoLogic periodoLogic = new PeriodoLogic();
        Periodo periodo = null;

        try {
            periodo = periodoLogic.getPeriodo(codperiodo);
        } catch (Exception e) {
            throw e;
        }

        return periodo;
    }

    public static List<Periodo> findByCriteriaInPeriodo(Object[] variables,
        Object[] variablesBetween, Object[] variablesBetweenDates)
        throws Exception {
        IPeriodoLogic periodoLogic = new PeriodoLogic();

        return periodoLogic.findByCriteria(variables, variablesBetween,
            variablesBetweenDates);
    }

    public static List<Periodo> findPagePeriodo(String sortColumnName,
        boolean sortAscending, int startRow, int maxResults)
        throws Exception {
        IPeriodoLogic periodoLogic = new PeriodoLogic();

        return periodoLogic.findPagePeriodo(sortColumnName, sortAscending,
            startRow, maxResults);
    }

    public static Long findTotalNumberPeriodo() throws Exception {
        IPeriodoLogic periodoLogic = new PeriodoLogic();

        return periodoLogic.findTotalNumberPeriodo();
    }

    public static List<Restauracion> getRestauracion()
        throws Exception {
        IRestauracionLogic restauracionLogic = new RestauracionLogic();

        return restauracionLogic.getRestauracion();
    }

    public static void saveRestauracion(Long codrestauracion, Date fechaactual,
        Date fechaplazo, Long codcuadro_Cuadro) throws Exception {
        IRestauracionLogic restauracionLogic = new RestauracionLogic();
        restauracionLogic.saveRestauracion(codrestauracion, fechaactual,
            fechaplazo, codcuadro_Cuadro);
    }

    public static void deleteRestauracion(Long codrestauracion)
        throws Exception {
        IRestauracionLogic restauracionLogic = new RestauracionLogic();
        restauracionLogic.deleteRestauracion(codrestauracion);
    }

    public static void updateRestauracion(Long codrestauracion,
        Date fechaactual, Date fechaplazo, Long codcuadro_Cuadro)
        throws Exception {
        IRestauracionLogic restauracionLogic = new RestauracionLogic();
        restauracionLogic.updateRestauracion(codrestauracion, fechaactual,
            fechaplazo, codcuadro_Cuadro);
    }

    public static Restauracion getRestauracion(Long codrestauracion)
        throws Exception {
        IRestauracionLogic restauracionLogic = new RestauracionLogic();
        Restauracion restauracion = null;

        try {
            restauracion = restauracionLogic.getRestauracion(codrestauracion);
        } catch (Exception e) {
            throw e;
        }

        return restauracion;
    }

    public static List<Restauracion> findByCriteriaInRestauracion(
        Object[] variables, Object[] variablesBetween,
        Object[] variablesBetweenDates) throws Exception {
        IRestauracionLogic restauracionLogic = new RestauracionLogic();

        return restauracionLogic.findByCriteria(variables, variablesBetween,
            variablesBetweenDates);
    }

    public static List<Restauracion> findPageRestauracion(
        String sortColumnName, boolean sortAscending, int startRow,
        int maxResults) throws Exception {
        IRestauracionLogic restauracionLogic = new RestauracionLogic();

        return restauracionLogic.findPageRestauracion(sortColumnName,
            sortAscending, startRow, maxResults);
    }

    public static Long findTotalNumberRestauracion() throws Exception {
        IRestauracionLogic restauracionLogic = new RestauracionLogic();

        return restauracionLogic.findTotalNumberRestauracion();
    }

    public static List<Sesion> getSesion() throws Exception {
        ISesionLogic sesionLogic = new SesionLogic();

        return sesionLogic.getSesion();
    }

    public static void saveSesion(Long codsesion, Double costopordia,
        Date fechaactual, Date fechaposibledevolucion, Long codcuadro_Cuadro,
        Long codmuseo_Museo) throws Exception {
        ISesionLogic sesionLogic = new SesionLogic();
        sesionLogic.saveSesion(codsesion, costopordia, fechaactual,
            fechaposibledevolucion, codcuadro_Cuadro, codmuseo_Museo);
    }

    public static void deleteSesion(Long codsesion) throws Exception {
        ISesionLogic sesionLogic = new SesionLogic();
        sesionLogic.deleteSesion(codsesion);
    }

    public static void updateSesion(Long codsesion, Double costopordia,
        Date fechaactual, Date fechaposibledevolucion, Long codcuadro_Cuadro,
        Long codmuseo_Museo) throws Exception {
        ISesionLogic sesionLogic = new SesionLogic();
        sesionLogic.updateSesion(codsesion, costopordia, fechaactual,
            fechaposibledevolucion, codcuadro_Cuadro, codmuseo_Museo);
    }

    public static Sesion getSesion(Long codsesion) throws Exception {
        ISesionLogic sesionLogic = new SesionLogic();
        Sesion sesion = null;

        try {
            sesion = sesionLogic.getSesion(codsesion);
        } catch (Exception e) {
            throw e;
        }

        return sesion;
    }

    public static List<Sesion> findByCriteriaInSesion(Object[] variables,
        Object[] variablesBetween, Object[] variablesBetweenDates)
        throws Exception {
        ISesionLogic sesionLogic = new SesionLogic();

        return sesionLogic.findByCriteria(variables, variablesBetween,
            variablesBetweenDates);
    }

    public static List<Sesion> findPageSesion(String sortColumnName,
        boolean sortAscending, int startRow, int maxResults)
        throws Exception {
        ISesionLogic sesionLogic = new SesionLogic();

        return sesionLogic.findPageSesion(sortColumnName, sortAscending,
            startRow, maxResults);
    }

    public static Long findTotalNumberSesion() throws Exception {
        ISesionLogic sesionLogic = new SesionLogic();

        return sesionLogic.findTotalNumberSesion();
    }

    public static List<Tecnica> getTecnica() throws Exception {
        ITecnicaLogic tecnicaLogic = new TecnicaLogic();

        return tecnicaLogic.getTecnica();
    }

    public static void saveTecnica(Long codtecnica, String nombretecnica)
        throws Exception {
        ITecnicaLogic tecnicaLogic = new TecnicaLogic();
        tecnicaLogic.saveTecnica(codtecnica, nombretecnica);
    }

    public static void deleteTecnica(Long codtecnica) throws Exception {
        ITecnicaLogic tecnicaLogic = new TecnicaLogic();
        tecnicaLogic.deleteTecnica(codtecnica);
    }

    public static void updateTecnica(Long codtecnica, String nombretecnica)
        throws Exception {
        ITecnicaLogic tecnicaLogic = new TecnicaLogic();
        tecnicaLogic.updateTecnica(codtecnica, nombretecnica);
    }

    public static Tecnica getTecnica(Long codtecnica) throws Exception {
        ITecnicaLogic tecnicaLogic = new TecnicaLogic();
        Tecnica tecnica = null;

        try {
            tecnica = tecnicaLogic.getTecnica(codtecnica);
        } catch (Exception e) {
            throw e;
        }

        return tecnica;
    }

    public static List<Tecnica> findByCriteriaInTecnica(Object[] variables,
        Object[] variablesBetween, Object[] variablesBetweenDates)
        throws Exception {
        ITecnicaLogic tecnicaLogic = new TecnicaLogic();

        return tecnicaLogic.findByCriteria(variables, variablesBetween,
            variablesBetweenDates);
    }

    public static List<Tecnica> findPageTecnica(String sortColumnName,
        boolean sortAscending, int startRow, int maxResults)
        throws Exception {
        ITecnicaLogic tecnicaLogic = new TecnicaLogic();

        return tecnicaLogic.findPageTecnica(sortColumnName, sortAscending,
            startRow, maxResults);
    }

    public static Long findTotalNumberTecnica() throws Exception {
        ITecnicaLogic tecnicaLogic = new TecnicaLogic();

        return tecnicaLogic.findTotalNumberTecnica();
    }

    public static List<Tipoestado> getTipoestado() throws Exception {
        ITipoestadoLogic tipoestadoLogic = new TipoestadoLogic();

        return tipoestadoLogic.getTipoestado();
    }

    public static void saveTipoestado(Long codtipoestado,
        String nombretipoestado) throws Exception {
        ITipoestadoLogic tipoestadoLogic = new TipoestadoLogic();
        tipoestadoLogic.saveTipoestado(codtipoestado, nombretipoestado);
    }

    public static void deleteTipoestado(Long codtipoestado)
        throws Exception {
        ITipoestadoLogic tipoestadoLogic = new TipoestadoLogic();
        tipoestadoLogic.deleteTipoestado(codtipoestado);
    }

    public static void updateTipoestado(Long codtipoestado,
        String nombretipoestado) throws Exception {
        ITipoestadoLogic tipoestadoLogic = new TipoestadoLogic();
        tipoestadoLogic.updateTipoestado(codtipoestado, nombretipoestado);
    }

    public static Tipoestado getTipoestado(Long codtipoestado)
        throws Exception {
        ITipoestadoLogic tipoestadoLogic = new TipoestadoLogic();
        Tipoestado tipoestado = null;

        try {
            tipoestado = tipoestadoLogic.getTipoestado(codtipoestado);
        } catch (Exception e) {
            throw e;
        }

        return tipoestado;
    }

    public static List<Tipoestado> findByCriteriaInTipoestado(
        Object[] variables, Object[] variablesBetween,
        Object[] variablesBetweenDates) throws Exception {
        ITipoestadoLogic tipoestadoLogic = new TipoestadoLogic();

        return tipoestadoLogic.findByCriteria(variables, variablesBetween,
            variablesBetweenDates);
    }

    public static List<Tipoestado> findPageTipoestado(String sortColumnName,
        boolean sortAscending, int startRow, int maxResults)
        throws Exception {
        ITipoestadoLogic tipoestadoLogic = new TipoestadoLogic();

        return tipoestadoLogic.findPageTipoestado(sortColumnName,
            sortAscending, startRow, maxResults);
    }

    public static Long findTotalNumberTipoestado() throws Exception {
        ITipoestadoLogic tipoestadoLogic = new TipoestadoLogic();

        return tipoestadoLogic.findTotalNumberTipoestado();
    }
}
